
<!--下载文件-->
<template>
  <span @click="downLoad">
    <slot />
  </span>
</template>
<script>
export default {
  name: 'FileDownload',
  props: {
    fileId: {
      type: String,
      required: false,
      default: ''
    }
  },
  data() {
    return {
    }
  },
  created() {
  },
  methods: {
    downLoad() {
      if (!this.fileId) {
        this.$modal.msgWarning('缺少参数fileId')
        return
      }
      this.$store.dispatch('downLoadFile', this.fileId).then(response => {
        console.log('文件下载：' + response.contentType)
        if (response.contentType === 'blob') {
          this.T.downloadFile(response)
        }
      })
    }
  }
}
</script>
<style lang="scss">
</style>
